package com.ai.entity.security.page;

import com.ai.entity.security.SysUser;
import com.ai.entity.comm.page.SysBasePage;
import com.alibaba.druid.util.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import lombok.extern.slf4j.Slf4j;

@Data
@Accessors(chain = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
@Slf4j
public class UserPage extends SysBasePage<SysUser> {

    @ApiModelProperty("账号")
    private String account;

    @ApiModelProperty(value = "用户名")
    private String userName;

    @ApiModelProperty("账号是否可用。默认为1（可用）")
    private String enabled;

    @ApiModelProperty("是否过期。默认为1（没有过期）")
    private String notExpired;

    @ApiModelProperty("账号是否锁定。默认为1（没有锁定）")
    private String accountNotLocked;

    @ApiModelProperty("证书（密码）是否过期。默认为1（没有过期）")
    private String credentialsNotExpired;

    @ApiModelProperty("创建人")
    private String createUser;

    public QueryWrapper<SysUser> getQuery(QueryWrapper<SysUser> queryWrapper) {
        return super.getQuery(queryWrapper)
                .eq((!StringUtils.isEmpty(account)), "account", account)
                .like((!StringUtils.isEmpty(userName)), "user_name", userName)
                .eq((!StringUtils.isEmpty(enabled) ), "enabled", enabled)
                .eq((!StringUtils.isEmpty(notExpired)), "not_expired", notExpired)
                .eq((!StringUtils.isEmpty(accountNotLocked)), "account_not_locked", accountNotLocked)
                .eq((!StringUtils.isEmpty(credentialsNotExpired) ), "credentials_not_expired", credentialsNotExpired)
                .eq((!StringUtils.isEmpty(createUser)), "create_user", createUser)
                ;
    }
}
